package com.example.elasticsearchhelpersample.repository.entity.params;

import org.elasticsearch.index.query.MultiMatchQueryBuilder;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.Base;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.EsCondition;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.EsQueryIndex;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.mapping.extend.RangeParam;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.module.Match;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.module.MultiMatch;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.module.Range;
import org.pippi.elasticsearch.helper.core.beans.annotation.query.module.Term;
import org.pippi.elasticsearch.helper.core.beans.enums.EsConnector;
import org.pippi.elasticsearch.helper.core.beans.enums.QueryModel;

import com.example.elasticsearchhelpersample.repository.entity.condition.UserConditions;

import lombok.Data;

/**
 * SimpleAccountQueryParam
 *
 * @author JohenTeng
 * @date 2021/12/9
 */
@Data
@EsQueryIndex(index = "account", model = QueryModel.BOOL)
public class SimpleAccountQueryParam {

	@Term(value = @Base(connect = EsConnector.FILTER))
	private String state;

	@Range(value = @Base(connect = EsConnector.FILTER), tag = Range.LE_GE)
	@EsCondition(UserConditions.AgeUserCondition.class)
	private RangeParam age;

	@Match(value = @Base(connect = EsConnector.SHOULD))
	private String address;

	@MultiMatch(
		value = @Base(connect = EsConnector.SHOULD),
		fields = {"firstname","employer","lastname"},
		type = MultiMatchQueryBuilder.Type.MOST_FIELDS,
		minimumShouldMatch = "1"
	)
	private String fuzzyField;
}
